package tts.model;

import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "usrDetails", catalog = "test")
public class UsrDetails implements java.io.Serializable {

	//fields
	private static final long serialVersionUID = -1409378059049963377L;
	private int usrDetails_id;
	private String name;
	private String surname;
	private Date birthdate;
	private String email;
	private String city;
	private String address;
	private String taxCode;
	private String phoneNumber;
	private String cellNumber;
	private Users users;

	//constructor
	public UsrDetails() {
		super();
	}

	public UsrDetails(String name, String surname, Date birthdate,
			String email, String city, String address, String taxCode,
			String phoneNumber, String cellNumber) {
		super();
		this.name = name;
		this.surname = surname;
		this.birthdate = birthdate;
		this.email = email;
		this.city = city;
		this.address = address;
		this.taxCode = taxCode;
		this.phoneNumber = phoneNumber;
		this.cellNumber = cellNumber;
	}

	//get & set
//	@Id
//	@GeneratedValue(generator = "gen")  
//	@GenericGenerator(name = "gen", strategy = "foreign", parameters =    @org.hibernate.annotations.Parameter(name = "property", value = "users"))
//	@Column(name="usrDetails_id", unique = true, nullable = false, length = 10, updatable = true)
	
	@Id
	@GeneratedValue
	@Column(name="usrDetails_id", unique = true, nullable = false, length = 10, updatable = true)
	public int getUsrDetails_id() {
		return usrDetails_id;
	}
	public void setUsrDetails_id(int usrDetails_id) {
		this.usrDetails_id = usrDetails_id;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "surname", nullable = false, length = 50)
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}

	@Column(name = "birthdate", nullable = true)
	public Date getBirthdate() {
		return birthdate;
	}
	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	@Column(name = "email", nullable = true, length = 50)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "city", nullable = true, length = 50)
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "address", nullable = true, length = 50)
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "taxCode", nullable = true, length = 50)
	public String getTaxCode() {
		return taxCode;
	}
	public void setTaxCode(String taxCode) {
		this.taxCode = taxCode;
	}

	@Column(name = "phoneNumber", nullable = true, length = 50)
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	@Column(name = "cellNumber", nullable = true, length = 50)
	public String getCellNumber() {
		return cellNumber;
	}
	public void setCellNumber(String cellNumber) {
		this.cellNumber = cellNumber;
	}
	
//	@OneToOne(fetch = FetchType.EAGER, cascade=javax.persistence.CascadeType.ALL, optional=false)
//	@PrimaryKeyJoinColumn
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "users_id", nullable = false, insertable = true, updatable = true)
	public Users getUsers() {
		return users;
	}
	public void setUsers(Users users) {
		this.users = users;
	}

	@Override
	public String toString() {
		return "UsrDetails [usrDetails_id=" + usrDetails_id + ", name=" + name
				+ ", surname=" + surname + ", birthdate=" + birthdate
				+ ", email=" + email + ", city=" + city + ", address="
				+ address + ", taxCode=" + taxCode + ", phoneNumber="
				+ phoneNumber + ", cellNumber=" + cellNumber + "]";
	}	
}